const BASE_API = 'http://39.99.151.246/api/';
import request from '../utils/request.js';

export function getDiy() {
	return request.get(BASE_API + 'v2/diy/get_diy/moren');
}


export function getCategoryList(){
	return request.get(BASE_API + 'category');
}

export function getUserInfo(){
	return request.get(BASE_API + "user",{noAuth: true});
}

export function loginH5(data){
	return request.post(BASE_API + "/login",data);
}

export function getMenuList(){
	return request.get(BASE_API + "menu/user", {},{noAuth: true});
}


// 获取热门商品
export function getProductHot(page,limit){
	 return request.get(BASE_API + "product/hot", { 
	    page: page === undefined ? 1 : page, 
	    limit:limit === undefined ? 4 :limit
	  },{noAuth: true});
}

// 获取商品详细信息
export function getProductslist(where){
	return request.get( BASE_API + 'products',where,{noAuth:true});
}

// 获取产品详细页面信息
export function getProductDetail(id){
	return request.get(BASE_API + 'product/detail/' + id, {}, { noAuth : true });
}

/**
 * 购车添加
 * 
*/
export function postCartAdd(data) {
  return request.post(BASE_API + 'cart/add', data);
}


// 获取地址信息列表
export function getAddressList(data){
	return request.get(BASE_API + 'address/list',data);
}

// 设置默认地址
export function setAddressDefault(id){
	 return request.post(BASE_API + 'address/default/set',{id});
}

// 获取地址详细信息
export function getAddressDetail(id){
	return request.get(BASE_API + 'address/detail/'+id);
}